package com.luxsoft.sw3.replica.replicadores;

import java.text.MessageFormat;

import org.apache.log4j.Logger;
import org.quartz.SchedulerException;
import org.quartz.SchedulerListener;
import org.quartz.Trigger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.luxsoft.utils.LoggerHelper;

public class ReplicadorJobListener implements SchedulerListener ,ApplicationContextAware {
	
	private ApplicationContext context;
	
	
	
	private static Logger log=LoggerHelper.getLogger();
	

	public void setApplicationContext(ApplicationContext applicationContext)throws BeansException {
		this.context=applicationContext;
	}



	public void jobScheduled(Trigger trigger) {
		// TODO Auto-generated method stub
		
	}



	public void jobUnscheduled(String triggerName, String triggerGroup) {
		
	}



	public void jobsPaused(String jobName, String jobGroup) {
		if(log.isDebugEnabled()){
			String pattern="Job detenido:{0} {1}";			
			log.debug(MessageFormat.format(pattern,jobName,jobGroup));
		}
		System.out.println("job detenido: "+jobName+ " - "+jobGroup);
	}



	public void jobsResumed(String jobName, String jobGroup) {
		if(log.isDebugEnabled()){
			String pattern="Job re iniciado:{0} {1}";			
			log.debug(MessageFormat.format(pattern,jobName,jobGroup));
		}
		System.out.println("job re iniciado: "+jobName+ " - "+jobGroup);
		
	}



	public void schedulerError(String msg, SchedulerException cause) {
		// TODO Auto-generated method stub
		
	}



	public void schedulerShutdown() {
		// TODO Auto-generated method stub
		
	}



	public void triggerFinalized(Trigger trigger) {
		// TODO Auto-generated method stub
		
	}



	public void triggersPaused(String triggerName, String triggerGroup) {
		System.out.println("Trigger paused: "+triggerName+ "  Group: "+triggerGroup);
		
	}



	public void triggersResumed(String triggerName, String triggerGroup) {
		// TODO Auto-generated method stub
		
	}

}
